//
//  HZTabBc.m
//  微博 OC
//
//  Created by 黑眼圈 on 16/4/18.
//  Copyright © 2016年 heiyan. All rights reserved.
//

#import "HZTabBc.h"
#import "HZHomeTc.h"
#import "HZMessageTc.h"
#import "HZDiscoverTc.h"
#import "HZProfileTc.h"
#import "HZTabBar.h"

@interface HZTabBc ()

@end

@implementation HZTabBc



- (void)viewDidLoad {
    [super viewDidLoad];
    

    //kvc设置底部的tabBar
    HZTabBar* bar = [[HZTabBar alloc]init];
    
    [self setValue:bar forKeyPath:@"self.tabBar"];
    
    //事先定义好 block
    bar.addBlock = ^{
        
        NSLog(@"加号按钮");
        
    };
    
 
    //添加的所有的子控制器
    [self addAllTc];
    
    
    
}




#pragma mark -
#pragma mark     添加的所有的子控制器
-(void)addAllTc{
    
    [self addViewController:@"首页" :[HZHomeTc new] :@"tabbar_home"];
    [self addViewController:@"消息" :[HZMessageTc new] :@"tabbar_message_center"];

    [self addViewController:@"发现" :[HZDiscoverTc new] :@"tabbar_discover"];
    
    [self addViewController:@"我" :[HZProfileTc new] :@"tabbar_profile"];

}


#pragma mark -
#pragma mark    添加子控制器
-(void)addViewController:(NSString*)nameString :(UITableViewController*)tc :(NSString*)imgName{
    
    
    tc.title = nameString;
    
    
    
    tc.tabBarItem.image = [UIImage imageNamed:imgName];
    
    //拼接选中的图片名称
    NSString* seleImgName = [NSString stringWithFormat:@"%@_selected",imgName];
    
    tc.tabBarItem.selectedImage = [UIImage imageNamed:seleImgName];
    
    
    
    //添加子控制器
    [self addChildViewController: [[UINavigationController alloc]initWithRootViewController:tc]];
    
}






















@end
